package com.ryzx.auth.vo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.ryzx.jpa.helper.base.BapBaseEntity;
import com.ryzx.jpa.helper.comment.Comment;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;

import java.util.HashSet;
import java.util.Set;

@Getter
@Setter
@Entity
@Inheritance(strategy= InheritanceType.JOINED)
@Comment("部门表")
@Table(name = "bap_dept")
public class BapDept extends BapBaseEntity {
    @Comment("名称")
    @Column(nullable = false, length = 30)
    private String name;
    @Comment("编码")
    @Column(nullable = false,unique = true,length = 30)
    private String code;
    @JsonIgnore
    @Comment("所属组织")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="org_id",nullable = false)
    private BapOrg bapOrg;

    @JsonIgnore
    @Comment("直属部门")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="parent_id")
    private BapDept parentDept;

    @JsonIgnore
    @ManyToMany(fetch = FetchType.LAZY)
    //其他管理部门，比如学校各院学办，除了受到直属学院管理以外，需接受学生处、教务处直接管理
    private Set<BapDept> otherParent = new HashSet<>();
}